package com.sk.controller;


import com.sk.entity.Orders;
import com.sk.service.IOrdersService;
import com.sk.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-05-28
 */
@RestController
@RequestMapping("/orders")
public class OrdersController {

    @Autowired
    private IOrdersService ordersService;

    @GetMapping("/{userId}")
    public Result getByUserId(@PathVariable("userId") Integer userId)
    {
        return ordersService.getByUserId(userId);
    }

    @PostMapping
    public Result saveorder(@RequestBody Orders order)
    {
        return ordersService.save(order);
    }

}
